import sys
import os
import requests

# sys.path.append("..")
# sys.path.append("../utils")
# os.environ.update({"DJANGO_SETTINGS_MODULE": "server.settings"})
# django.setup()
# from django.test import Client

# client = Client()

baseUrl = u"http://127.0.0.1:8000/api/storehouse/"


def storehouseAdd():
    iputData = {
        "storehouseName": "分布式仓库1",
        "storehouseType": "分布式",
        "storehouseDetails": "分布式",
        "linkName": "666",
        "linkPhone": "111",
        "warZoneId": "1",
        "companyId": "1",
        "storeIP": "",
        "storePort": "",
    }
    res = requests.post(baseUrl + 'add/', data=iputData)
    print(res.content)


def getStorehouseInfo():
    iputData = {
        "token": "15f3911902953e46ce92",
    }
    res = requests.post(baseUrl + 'msgshow/', data=iputData)
    print(res.content)


def changeStorehouseInfo():
    iputData = {
        "storehouseId": "2",
        "storehouseName": "J仓库",
        "storehouseType": "A计算",
        "storehouseDetails": "A与计算相关",
        "linkName": "A666",
        "linkPhone": "A111",
        "warZoneId": "2",
        "companyId": "2",
        "token": "80dd9bc3de1a768f6d41",
    }
    res = requests.post(baseUrl + 'msgchange/', data=iputData)
    print(res.content)


def getIPList():
    iputData = {
        "token": "80dd9bc3de1a768f6d41",
        'page': '1',
        'maxItem': '5',
    }
    res = requests.post(baseUrl + 'IPget/', data=iputData)
    print(res.content)


def IPChange():
    iputData = {
        "token": "a45eb477cf7417ab74d0",
        "connectIP": "127.0.0.1",
        "connectPort": "8000",
        "isMasterStore": '',
    }
    res = requests.post(baseUrl + 'IPchange/', data=iputData)
    print(res.content)


def getSubStoreList():
    iputData = {
        "token": "80dd9bc3de1a768f6d41",
        'page': '1',
        'maxItem': '5',
    }
    res = requests.post(baseUrl + 'list/', data=iputData)
    print(res.content)


def subStorehouseMsg():
    iputData = {
        "storehouseId": "3",
        "token": "80dd9bc3de1a768f6d41",
    }
    res = requests.post(baseUrl + 'subInfo/', data=iputData)
    print(res.content)


def getWarZoneList():
    iputData = {
        "token": "80dd9bc3de1a768f6d41",
        'page': '1',
        'maxItem': '5',
    }
    res = requests.post(baseUrl + 'warzone/', data=iputData)
    print(res.content)


def getComapnyList():
    iputData = {
        "token": "80dd9bc3de1a768f6d41",
        'page': '1',
        'maxItem': '5',
        "warZoneId": '5',
    }
    res = requests.post(baseUrl + 'company/', data=iputData)
    print(res.content)


def storehouseOperation():
    iputData = {
        "token": "80dd9bc3de1a768f6d41",
        'storehouseId': '5',
        'operation': '0',
    }
    res = requests.post(baseUrl + 'operations/', data=iputData)
    print(res.content)


def storeScreen():
    iputData = {
        "token": "61aa3da28253d3877c20",
        'page': '1',
        'maxItem': '5',
        "warZoneId": "",
        "companyId": "",
        "runState": '',
        "connectstate": 1,
        "storehouseName": "",
    }
    res = requests.post(baseUrl + 'screen/', data=iputData)
    print(res.content)


def getSelect():
    iputData = {
        "token": "80dd9bc3de1a768f6d41",
    }
    res = requests.post(baseUrl + 'getselect/', data=iputData)
    print(res.content)


def warzoneGet():
    iputData = {
        "token": "15f3911902953e46ce92",
        'page': '1',
        'maxItem': '5',
    }
    res = requests.post(baseUrl + 'warZoneList/', data=iputData)
    print(res.content)


def zoneOption():
    iputData = {
        "token": "15f3911902953e46ce92",
        'warZoneId': '5',
        'zoneType': '1',
        'name': '',
        'option': '2',
    }
    res = requests.post(baseUrl + 'warZoneOption/', data=iputData)
    print(res.content)


def companyGet():
    iputData = {
        "token": "15f3911902953e46ce92",
        'page': '1',
        'maxItem': '15',
        'warZoneId': '',
    }
    res = requests.post(baseUrl + 'companyList/', data=iputData)
    print(res.content)


def companyOption():
    iputData = {
        "token": "15f3911902953e46ce92",
        'warZoneId': '3',
        'state': '1',
        'id': '3',
        'name': '空军',
        'option': '2',
    }
    res = requests.post(baseUrl + 'companyOption/', data=iputData)
    print(res.content)


if __name__ == '__main__':
    # storehouseAdd()
    # getStorehouseInfo()
    # changeStorehouseInfo()
    # getIPList()
    # IPChange()
    # getSubStoreList()
    # subStorehouseMsg()
    # getWarZoneList()
    # getComapnyList()
    # storehouseOperation()
    # storeScreen()
    # getSelect()
    # warzoneGet()
    # zoneOption()
    # companyGet()
    companyOption()
